home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / SASC_6.0_Disk_3.adf / Compiler_headers / Include / math.h < prev    next >
C/C++ Source or Header  |  1992-07-30  |  4KB  |  184 lines

  1. /* Copyright (c) 1992 SAS Institute, Inc., Cary, NC USA */
  2. /* All Rights Reserved */
  3.  
  4.  
  5. #ifndef _MATH_H
  6. #define _MATH_H 1
  7.  
  8. #ifndef HUGE_VAL
  9. #ifdef _FFP
  10. #define HUGE_VAL 9.2337177e18
  11. #else
  12. #define HUGE_VAL 1.797693134862317E+308
  13. #endif
  14. #endif
  15.  
  16.  
  17. /***
  18. *     ANSI trigonometric functions
  19. ***/
  20.  
  21. #ifndef __ARGS
  22. #define __ARGS(x) x
  23. #endif
  24.  
  25. /* Use the __ARGS macro below to suppress errors  */
  26. /* if these functions have been #defined by other */
  27. /* header files.                                  */
  28.  
  29. extern double acos  __ARGS((double));
  30. extern double asin  __ARGS((double));
  31. extern double atan  __ARGS((double));
  32. extern double atan2 __ARGS((double, double));
  33. extern double cos   __ARGS((double));
  34. extern double sin   __ARGS((double));
  35. extern double tan   __ARGS((double));
  36.  
  37.  
  38. /***
  39. *     ANSI hyperbolic functions
  40. ***/
  41.  
  42. extern double cosh __ARGS((double));
  43. extern double sinh __ARGS((double));
  44. extern double tanh __ARGS((double));
  45.  
  46.  
  47. /***
  48. *     ANSI exponential and logarithmic functions
  49. ***/
  50.  
  51. extern double exp __ARGS((double));
  52. extern double frexp __ARGS((double, int *));
  53. extern double ldexp __ARGS((double, int));
  54. extern double log __ARGS((double));
  55. extern double log10 __ARGS((double));
  56. extern double modf __ARGS((double, double *));
  57.  
  58.  
  59. /***
  60. *     ANSI power functions
  61. ***/
  62.  
  63. extern double pow __ARGS((double, double));
  64. extern double sqrt __ARGS((double));
  65.  
  66.  
  67. /***
  68. *     ANSI nearest integer, absolute value, and remainder functions
  69. ***/
  70.  
  71. extern double ceil __ARGS((double));
  72. extern double fabs __ARGS((double));
  73. extern double floor __ARGS((double));
  74. extern double fmod __ARGS((double, double));
  75.  
  76.  
  77. /***
  78. *     Structure to hold information about math exceptions
  79. ***/
  80.  
  81. struct __exception {
  82.     int     type;          /* error type */
  83.     char    *name;         /* math function name */
  84.     double  arg1, arg2;    /* function arguments */
  85.     double  retval;        /* proposed return value */
  86. };
  87.  
  88. /***
  89. *     Exception type codes, found exception.type
  90. ***/
  91.  
  92. #define _DOMAIN      1    /* domain error */
  93. #define _SING        2    /* singularity */
  94. #define _OVERFLOW    3    /* overflow */
  95. #define _UNDERFLOW   4    /* underflow */
  96. #define _TLOSS       5    /* total loss of significance */
  97. #define _PLOSS       6    /* partial loss of significance */
  98. #define _RANGE       6    /* range error */
  99.  
  100.  
  101. /***
  102. *     Error codes generated by basic arithmetic operations (+ - * /)
  103. ***/
  104.  
  105. #define _FPEUND      1    /* underflow */
  106. #define _FPEOVF      2    /* overflow */
  107. #define _FPEZDV      3    /* zero divisor */
  108. #define _FPENAN      4    /* not a number (invalid operation) */
  109. #define _FPECOM      5    /* not comparable */
  110.  
  111. extern int _FPERR;
  112.  
  113. #ifndef _STRICT_ANSI
  114.  
  115. #define DOMAIN    _DOMAIN
  116. #define SING      _SING
  117. #define OVERFLOW  _OVERFLOW
  118. #define UNDERFLOW _UNDERFLOW
  119. #define TLOSS     _TLOSS
  120. #define PLOSS     _PLOSS
  121. #define RANGE     _RANGE
  122.  
  123. #define FPEUND    _FPEUND
  124. #define FPEOVF    _FPEOVF
  125. #define FPEZDV    _FPEZDV
  126. #define FPENAN    _FPENAN
  127. #define FPECOM    _FPECOM
  128.  
  129. /***
  130. *     Floating point constants
  131. ***/
  132.  
  133. #define PI      3.14159265358979323846
  134. #define PID2    1.57079632679489661923       /*  PI/2  */
  135. #define PID4    0.78539816339744830962       /*  PI/4  */
  136. #define I_PI    0.31830988618379067154       /*  1/PI  */
  137. #define I_PID2  0.63661977236758134308       /*  1/(PI/2)  */
  138.  
  139. #define HUGE      HUGE_VAL
  140.  
  141. #ifdef _FFP
  142. #define TINY      5.42101070e-20
  143. #define LOGHUGE   4.366827e1
  144. #define LOGTINY  -3.922479e1
  145. #else
  146. #define TINY      2.2e-308
  147. #define LOGHUGE   709.778
  148. #define LOGTINY  -708.396
  149. #endif
  150.  
  151. /***
  152. *     SAS functions (Non-ANSI)
  153. ***/
  154.  
  155. void __stdargs _CXFERR(int);
  156. extern double cot(double);
  157. extern double drand48(void);
  158. extern double erand48(unsigned short *);
  159. extern double except(int, char *, double, double, double);
  160. extern char   *ecvt(double, int, int *, int *);
  161. extern char   *fcvt(double, int, int *, int *);
  162. extern char   *gcvt(double, int, char *);
  163. extern long   jrand48(unsigned short *);
  164. extern void   lcong48(unsigned short *);
  165. extern long   lrand48(void);
  166. extern double __except(int, char *, double, double, double);
  167. extern int    __matherr(struct __exception *);
  168. extern long   mrand48(void);
  169. extern long   nrand48(unsigned short *);
  170. extern double pow2(double);
  171. extern unsigned short *seed48(unsigned short *);
  172. extern void   srand48(long);
  173.  
  174. #ifndef max
  175. #define   max(a,b)    ((a) > (b) ? (a) : (b))
  176. #endif
  177. #ifndef min
  178. #define   min(a,b)    ((a) <= (b) ? (a) : (b))
  179. #endif
  180.  
  181. #endif /* _STRICT_ANSI */
  182.  
  183. #endif
  184.